/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPanelAltaSeccion.java
 *
 * Created on 5/05/2012, 01:34:24 AM
 */
package vista.panel;

import controlador.ControladorPrincipal;
import modelo.Lider;

/**
 *
 * @author Elias Mendoza
 */
public class JPanelAltaLider extends javax.swing.JPanel {

    /** Creates new form JPanelAltaSeccion */
    static ControladorPrincipal accion;
    private static JPanelAltaLider panelAltaLider = null;

    private JPanelAltaLider() {
        initComponents();
        accion = new ControladorPrincipal();

    }

    public static JPanelAltaLider getPanelAltaLider() {
        if (panelAltaLider == null) {
            panelAltaLider = new JPanelAltaLider();
        }
        return panelAltaLider;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabelColonias = new javax.swing.JLabel();
        jTextFieldNombre = new javax.swing.JTextField();
        jButtonRegistrar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();

        setBackground(new java.awt.Color(255, 255, 255));
        setLayout(new java.awt.GridBagLayout());

        jLabelColonias.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jLabelColonias.setText("Nombre del nuevo Lider:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.ipadx = 1;
        gridBagConstraints.ipady = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(17, 13, 0, 0);
        add(jLabelColonias, gridBagConstraints);

        jTextFieldNombre.setFont(new java.awt.Font("Times New Roman", 1, 12));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.ipadx = 292;
        gridBagConstraints.ipady = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints.insets = new java.awt.Insets(15, 14, 0, 0);
        add(jTextFieldNombre, gridBagConstraints);

        jButtonRegistrar.setFont(new java.awt.Font("Maiandra GD", 1, 12));
        jButtonRegistrar.setText("Registrar");
        jButtonRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegistrarActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.gridheight = 2;
        gridBagConstraints.ipadx = 4;
        gridBagConstraints.ipady = 6;
        gridBagConstraints.insets = new java.awt.Insets(12, 1, 16, 0);
        add(jButtonRegistrar, gridBagConstraints);

        jLabel1.setFont(new java.awt.Font("Calibri", 1, 18));
        jLabel1.setText("Registrar Nuevo Lider");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 6;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 20;
        add(jLabel1, gridBagConstraints);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(new java.awt.GridBagLayout());
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.insets = new java.awt.Insets(6, 18, 5, 11);
        add(jPanel1, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents

  private void jButtonRegistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegistrarActionPerformed
      // TODO add your handling code here:

      if (!jTextFieldNombre.getText().isEmpty()) {
          Lider lider = new Lider();
          lider.setNombre(jTextFieldNombre.getText());
          accion.registrar(lider, 0);
      }
  }//GEN-LAST:event_jButtonRegistrarActionPerformed
// public void paint(Graphics g) {
//    Image imagen = new ImageIcon(getClass().getResource("/vista/img/fondo_for.png")).getImage();
//    g.drawImage(imagen, 0, 0, getWidth(), getHeight(), null);
//    setOpaque(false);
//    super.paintComponent(g);
//  }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton jButtonRegistrar;
    public javax.swing.JLabel jLabel1;
    public javax.swing.JLabel jLabelColonias;
    public javax.swing.JPanel jPanel1;
    public javax.swing.JTextField jTextFieldNombre;
    // End of variables declaration//GEN-END:variables
}
